<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/dute_favicon_32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/dute_favicon_16x16.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">
  <link rel="manifest" href="/images/manifest.json">
  <meta name="msapplication-config" content="/images/browserconfig.xml">
  <meta http-equiv="Cache-Control" content="no-transform">
  <meta http-equiv="Cache-Control" content="no-siteapp">
  <meta name="google-site-verification" content="mpI5dkydstZXl6UcDCppqktXK0bbvqdZ6LkZ3KNk4Iw">
  <meta name="baidu-site-verification" content="code-a1LksZX2Ds">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"whitestore.top","root":"/","scheme":"Gemini","version":"7.8.0","exturl":true,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":true,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":true,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="随遇而安">
<meta property="og:type" content="website">
<meta property="og:title" content="爱看书的阿东">
<meta property="og:url" content="https://whitestore.top/page/4/index.html">
<meta property="og:site_name" content="爱看书的阿东">
<meta property="og:description" content="随遇而安">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="阿东">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://whitestore.top/page/4/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>

  <title>爱看书的阿东 - 赐他一块白色石头，石头上写着新名</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="爱看书的阿东" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">爱看书的阿东</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">赐他一块白色石头，石头上写着新名</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
        <li class="menu-item menu-item-sitemap">

    <a href="/sitemap.xml" rel="section"><i class="fa fa-fw fa-sitemap"></i>站点地图</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    

  <span class="exturl github-corner" data-url="aHR0cHM6Ly9naXRodWIuY29tL2xhenlUaW1lcw==" title="Follow me on GitHub" aria-label="Follow me on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></span>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://whitestore.top/2023/06/15/mysqlcharacter/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="阿东">
      <meta itemprop="description" content="随遇而安">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="爱看书的阿东">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/06/15/mysqlcharacter/" class="post-title-link" itemprop="url">【Mysql】How to store UTF8 characters in MySQL</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-06-15 10:59:40" itemprop="dateCreated datePublished" datetime="2023-06-15T10:59:40+08:00">2023-06-15</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2023-07-16 14:28:09" itemprop="dateModified" datetime="2023-07-16T14:28:09+08:00">2023-07-16</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Mysql/" itemprop="url" rel="index"><span itemprop="name">Mysql</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/06/15/mysqlcharacter/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/06/15/mysqlcharacter/" itemprop="commentCount"></span>
    </a>
  </span>
  
  <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>3.1k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>3 分钟</span>
            </span>
            <div class="post-description">请输入描述信息</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="原文"><a href="#原文" class="headerlink" title="原文"></a>原文</h1><p><span class="exturl" data-url="aHR0cHM6Ly91YmlxLmNvL2RhdGFiYXNlLWJsb2cvaG93LXRvLXN0b3JlLXV0ZjgtY2hhcmFjdGVycy1pbi1teXNxbC8=" title="https://ubiq.co/database-blog/how-to-store-utf8-characters-in-mysql/">How to store UTF8 characters in MySQL - Ubiq BI<i class="fa fa-external-link"></i></span></p>
<h1 id="引言"><a href="#引言" class="headerlink" title="引言"></a>引言</h1><p>关于 <strong>《如何在MySQL中存储UTF8字符》</strong> 的一篇英文博客阅读和个人实战笔记。注意个人实验过程中使用了docker的Mysql 5.7 版本，读者可以根据自身情况调整。</p>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2023/06/15/mysqlcharacter/#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://whitestore.top/2023/06/15/mysqlconnection/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="阿东">
      <meta itemprop="description" content="随遇而安">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="爱看书的阿东">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/06/15/mysqlconnection/" class="post-title-link" itemprop="url">【Mysql】How to Increase Max Connections in MySQL</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-06-15 10:07:14" itemprop="dateCreated datePublished" datetime="2023-06-15T10:07:14+08:00">2023-06-15</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2023-07-16 14:28:09" itemprop="dateModified" datetime="2023-07-16T14:28:09+08:00">2023-07-16</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Mysql/" itemprop="url" rel="index"><span itemprop="name">Mysql</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/06/15/mysqlconnection/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/06/15/mysqlconnection/" itemprop="commentCount"></span>
    </a>
  </span>
  
  <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>2k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>2 分钟</span>
            </span>
            <div class="post-description">最大连接数</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="原文"><a href="#原文" class="headerlink" title="原文"></a>原文</h1><p><span class="exturl" data-url="aHR0cHM6Ly91YmlxLmNvL2RhdGFiYXNlLWJsb2cvaG93LXRvLWluY3JlYXNlLW1heC1jb25uZWN0aW9ucy1pbi1teXNxbC8=" title="https://ubiq.co/database-blog/how-to-increase-max-connections-in-mysql/">https://ubiq.co/database-blog/how-to-increase-max-connections-in-mysql/<i class="fa fa-external-link"></i></span></p>
<h1 id="引言"><a href="#引言" class="headerlink" title="引言"></a>引言</h1><p>有时候连接Mysql时候我们会遇到“Too many connections”这样的报错，当然更多可能是在生产过程中碰到这样的问题，默认情况下Mysql的整体服务器连接数设置过低。</p>
<blockquote>
<p>Sometimes MySQL server may give “Too many connections” error message when you try to connect to a MySQL database. Here’s how to increase max connections in MySQL to fix this problem.</p>
</blockquote>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2023/06/15/mysqlconnection/#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://whitestore.top/2023/03/19/jdk11update/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="阿东">
      <meta itemprop="description" content="随遇而安">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="爱看书的阿东">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/03/19/jdk11update/" class="post-title-link" itemprop="url">【JAVA】JDK11新特性个人分析</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-03-19 15:45:58" itemprop="dateCreated datePublished" datetime="2023-03-19T15:45:58+08:00">2023-03-19</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2023-06-15 21:10:39" itemprop="dateModified" datetime="2023-06-15T21:10:39+08:00">2023-06-15</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java/" itemprop="url" rel="index"><span itemprop="name">Java</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/03/19/jdk11update/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/03/19/jdk11update/" itemprop="commentCount"></span>
    </a>
  </span>
  
  <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>26k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>24 分钟</span>
            </span>
            <div class="post-description">JDK11</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="历史背景"><a href="#历史背景" class="headerlink" title="历史背景"></a>历史背景</h1><p>2018年9 月 26 日，Oracle 官方宣布 Java 11 正式发布。这个版本中一共包含 <strong>17 个 JEP（JDK Enhancement Proposals，JDK 增强提案）</strong>。</p>
<p><strong>JDK 11 是一个长期支持版本（LTS, Long-Term-Support）</strong>，在编写本文的时间节点下和JDK17一样被用于编写项目代码的主流版本。</p>
<p>本文结合了各方资料整理出JDK11的新特性，工作上使用高版本JDK的机会确实不多，但是自己体验的过程中确实切身体会到JDK升级的好处。</p>
<h2 id="升级JDK11的意义"><a href="#升级JDK11的意义" class="headerlink" title="升级JDK11的意义"></a>升级JDK11的意义</h2><ul>
<li>大量的新特性、Bug 修复，例如，容器环境支持，GC 等基础领域的增强。</li>
<li>安全协议更新，比如废弃TLS1.2中不安全的加密算法，部分支持TLS1.3协议。</li>
<li>JVM的零成本优化。</li>
<li>划时代的<strong>垃圾收集器ZGC</strong>，关键目的是实现GC时间不超过10ms。</li>
<li><strong>G1垃圾收集器的免费升级</strong><ul>
<li>并行的 Full GC（JDK11之前Oracle没有考虑过G1需要并行Full GC）</li>
<li>快速的 CardTable 扫描</li>
<li>自适应的堆占用比例调整（IHOP）</li>
<li>在并发标记阶段的类型卸载</li>
</ul>
</li>
<li><strong>JVM自带工具增强</strong><ul>
<li>JEP 328: <strong>Flight Recorder（JFR）</strong>，商用版工具JFR转为开源。</li>
<li>JEP 331: <strong>Low-Overhead Heap Profiling</strong> 实现底层成本堆分析JVM扩展</li>
</ul>
</li>
<li>TLS协议精简<ul>
<li>完善Java标准HTTP类库上的扩展能力。</li>
<li>JEP 332: Transport Layer Security (TLS) 1.3，完全支持<strong>TLS 1.3</strong>（协议部分部分支持，加密算法部分基本满足要求）。</li>
</ul>
</li>
<li><strong>HTTP/2 Client API</strong><ul>
<li>完善了Java语言自身进行Http Client的能力</li>
<li>等同于把HttpClient官方化（难听点就是搬来了）</li>
<li><s>只要不写作者，谁也不知道自己写的还是抄的谁的</s></li>
</ul>
</li>
<li>废弃Nashorn JavaScript引擎<ul>
<li>实际上是全力推动Graal VM虚拟机的开发。</li>
</ul>
</li>
</ul>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2023/03/19/jdk11update/#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://whitestore.top/2023/03/15/apioperate/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="阿东">
      <meta itemprop="description" content="随遇而安">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="爱看书的阿东">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/03/15/apioperate/" class="post-title-link" itemprop="url">【Java】@ApiOperation vs @ApiResponse in Swagger</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2023-03-15 15:00:09 / 修改时间：15:01:21" itemprop="dateCreated datePublished" datetime="2023-03-15T15:00:09+08:00">2023-03-15</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java/" itemprop="url" rel="index"><span itemprop="name">Java</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/03/15/apioperate/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/03/15/apioperate/" itemprop="commentCount"></span>
    </a>
  </span>
  
  <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>4k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>4 分钟</span>
            </span>
            <div class="post-description">Java的注解使用</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="原文"><a href="#原文" class="headerlink" title="原文"></a>原文</h1><p><span class="exturl" data-url="aHR0cHM6Ly93d3cuYmFlbGR1bmcuY29tL3N3YWdnZXItYXBpb3BlcmF0aW9uLXZzLWFwaXJlc3BvbnNl" title="https://www.baeldung.com/swagger-apioperation-vs-apiresponse">https://www.baeldung.com/swagger-apioperation-vs-apiresponse<i class="fa fa-external-link"></i></span></p>
<h1 id="引言"><a href="#引言" class="headerlink" title="引言"></a>引言</h1><p>本文内容讨论的是 <em>@ApiOperation</em> 和 <em>@ApiResponse</em> 注解的优劣。</p>
<h1 id="介绍Swagger"><a href="#介绍Swagger" class="headerlink" title="介绍Swagger"></a>介绍Swagger</h1><p>一个RestFul最重要的是具备“自描述能力”，所谓的自描述能力是能在返回结果的同时，告知客户端调用下<br>一步的行为，Swagger在一定程度上封装和规范了这些操作。</p>
<p>什么是Swagger？</p>
<blockquote>
<p>Swagger represents a set of open-source tools built around OpenAPI Specification. It can help us design, build, document, and consume REST APIs.</p>
</blockquote>
<p>Swagger代表了一套围绕OpenAPI规范建立的开源工具。它可以帮助我们设计、构建、记录REST APIs接口。其中最为常用的注解便是 @ApiOperation 和 @ApiResponse。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@RestController</span></span><br><span class="line"><span class="meta">@RequestMapping</span>(<span class="string">"/customers"</span>)</span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">CustomerController</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">   <span class="keyword">private</span> <span class="keyword">final</span> CustomerService customerService;</span><br><span class="line"></span><br><span class="line">   <span class="function"><span class="keyword">public</span> <span class="title">CustomerController</span><span class="params">(CustomerService customerService)</span> </span>&#123;</span><br><span class="line">       <span class="keyword">this</span>.customerService = customerService;</span><br><span class="line">   &#125;</span><br><span class="line">  </span><br><span class="line">   <span class="meta">@GetMapping</span>(<span class="string">"/&#123;id&#125;"</span>)</span><br><span class="line">   <span class="function"><span class="keyword">public</span> ResponseEntity&lt;CustomerResponse&gt; <span class="title">getCustomer</span><span class="params">(@PathVariable(<span class="string">"id"</span>)</span> Long id) </span>&#123;</span><br><span class="line">       <span class="keyword">return</span> ResponseEntity.ok(customerService.getById(id));</span><br><span class="line">   &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>下面分别介绍这两个注解的使用，最后是进行对比。</p>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2023/03/15/apioperate/#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://whitestore.top/2023/03/15/bestjavacoding/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="阿东">
      <meta itemprop="description" content="随遇而安">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="爱看书的阿东">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/03/15/bestjavacoding/" class="post-title-link" itemprop="url">【Java】Best coding practices every java</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2023-03-15 14:55:58 / 修改时间：14:58:01" itemprop="dateCreated datePublished" datetime="2023-03-15T14:55:58+08:00">2023-03-15</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java/" itemprop="url" rel="index"><span itemprop="name">Java</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/03/15/bestjavacoding/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/03/15/bestjavacoding/" itemprop="commentCount"></span>
    </a>
  </span>
  
  <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>9.8k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>9 分钟</span>
            </span>
            <div class="post-description">java规范案例</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="原文"><a href="#原文" class="headerlink" title="原文"></a>原文</h1><p><span class="exturl" data-url="aHR0cHM6Ly9tZWRpdW0uY29tL0BhYmhpc2hla3NpbmdoamF2YS9iZXN0LWNvZGluZy1wcmFjdGljZXMtZXZlcnktamF2YS1kZXZlbG9wZXItc2hvdWxkLWZvbGxvdy03Yjc3NTI3YTcwNDgjaWRfdG9rZW49ZXlKaGJHY2lPaUpTVXpJMU5pSXNJbXRwWkNJNklqSTFOV05qWVRabFl6STRNVEEyTURKa09EQmlaV000T1dVME5UWmpORFE1TldRM05ERTRZbUlpTENKMGVYQWlPaUpLVjFRaWZRLmV5SnBjM01pT2lKb2RIUndjem92TDJGalkyOTFiblJ6TG1kdmIyZHNaUzVqYjIwaUxDSnVZbVlpT2pFMk56Z3pOekEzTkRVc0ltRjFaQ0k2SWpJeE5qSTVOakF6TlRnek5DMXJNV3MyY1dVd05qQnpNblJ3TW1FeWFtRnROR3hxWkdOdGN6QXdjM1IwWnk1aGNIQnpMbWR2YjJkc1pYVnpaWEpqYjI1MFpXNTBMbU52YlNJc0luTjFZaUk2SWpFd01qVXpOakF3TmpZMU1UQTVORFF4TnpNNE15SXNJbVZ0WVdsc0lqb2llbmhrYzJJMk5qWkFaMjFoYVd3dVkyOXRJaXdpWlcxaGFXeGZkbVZ5YVdacFpXUWlPblJ5ZFdVc0ltRjZjQ0k2SWpJeE5qSTVOakF6TlRnek5DMXJNV3MyY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vvG7yHMAH0R51l7xn-nUMlMnKZN12wb-VZCSbw86d4-kKgrr9b18dP7R3JDlNhUo3CEL5lwZpPWdMj3gHzRw0ZBr94HWLSg">Best coding practices every java developer should follow<i class="fa fa-external-link"></i></span></p>
<h2 id="目录"><a href="#目录" class="headerlink" title="目录"></a>目录</h2><ul>
<li><a href="#引言">引言</a></li>
<li><a href="#4-尽可能让变量私有化">4. 尽可能让变量私有化</a></li>
<li><a href="#6-警惕冗余初始化">6. 警惕冗余初始化</a></li>
<li><a href="#5-Stringbuilder替换字符串拼接争议">5. Stringbuilder替换字符串拼接【争议】</a></li>
<li><a href="#15-dry和kiss">15. dry和kiss</a></li>
<li><a href="#14-Solid">14. Solid</a></li>
<li><a href="#7-尽可能使用增强for循环或者foreach">7. 尽可能使用增强for循环或者foreach</a></li>
<li><a href="#13-日志打印规则">13. 日志打印规则</a></li>
<li><a href="#12-Hardcoding硬编码">12. Hardcoding硬编码</a></li>
<li><a href="#11-注释">11. 注释</a></li>
<li><a href="#10-避免创建不必要对象">10. 避免创建不必要对象</a></li>
<li><a href="#9-返回空集合而不是null">9. 返回空集合而不是null</a></li>
<li><a href="#8-精度选择">8. 精度选择</a></li>
<li><a href="#1-项目结构">1. 项目结构</a></li>
<li><a href="#2-遵循命名规范">2. 遵循命名规范</a></li>
<li><a href="#3-不要吞异常">3. 不要吞异常</a></li>
<li><a href="#16-使用枚举替代静态常量建议">16. 使用枚举替代静态常量【建议】</a></li>
<li><a href="#17-按作用域划分成员变量">17. 按作用域划分成员变量</a></li>
<li><a href="#18-在数字字段中使用下划线建议">18. 在数字字段中使用下划线【建议】</a></li>
<li><a href="#总结">总结</a></li>
<li><a href="#参考">参考</a></li>
</ul>
<h1 id="引言"><a href="#引言" class="headerlink" title="引言"></a>引言</h1><p>把标题翻译成中文在国内也是一个老生常谈的问题：编程习惯和编码规范。</p>
<p>这篇文章大部分观点和国内的规范习惯类似，令我好奇的是外国人是如何理解这些内容的？</p>
<p>注意本文的Tips排序是打乱的，个人把感兴趣放到了前面来了。这篇文章的评论区非常精彩，这里一并整合了评论区的读者观点。</p>
<p>不管是学习还是了解老外的思考方式，或是在评论区当中看读者的讨论和纠正错误，阅读本文都是值得推荐的。</p>
<p>抱着半信半疑的态度学习这些内容，你会得到比单纯的了解和接受建议更多的收获。</p>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2023/03/15/bestjavacoding/#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://whitestore.top/2023/03/15/stdinouterr/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="阿东">
      <meta itemprop="description" content="随遇而安">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="爱看书的阿东">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/03/15/stdinouterr/" class="post-title-link" itemprop="url">【Linux】How to Use the Stdin, Stderr, and Stdout Streams in Bash</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2023-03-15 14:49:31 / 修改时间：14:50:44" itemprop="dateCreated datePublished" datetime="2023-03-15T14:49:31+08:00">2023-03-15</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Linux/" itemprop="url" rel="index"><span itemprop="name">Linux</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/03/15/stdinouterr/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/03/15/stdinouterr/" itemprop="commentCount"></span>
    </a>
  </span>
  
  <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>5.9k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>5 分钟</span>
            </span>
            <div class="post-description">流介绍</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="How-to-Use-the-Stdin-Stderr-and-Stdout-Streams-in-Bash"><a href="#How-to-Use-the-Stdin-Stderr-and-Stdout-Streams-in-Bash" class="headerlink" title="How to Use the Stdin, Stderr, and Stdout Streams in Bash"></a>How to Use the Stdin, Stderr, and Stdout Streams in Bash</h1><h2 id="目录"><a href="#目录" class="headerlink" title="目录"></a>目录</h2><ul>
<li><a href="#原文">原文</a></li>
<li><a href="#引言">引言</a><ul>
<li><a href="#Redirection-Operators-of-Stdin-Stdout-and-Stderr">Redirection Operators of Stdin, Stdout, and Stderr</a></li>
</ul>
</li>
<li><a href="#Uses-of-Stdin-Stdout-and-Stderr">Uses of Stdin, Stdout, and Stderr</a></li>
<li><a href="#Example-1-Use-of-Stdin">Example 1: Use of Stdin</a><ul>
<li><a href="#-等操作符使用">&gt;、&gt;&gt;、&lt; 等操作符使用</a></li>
</ul>
</li>
<li><a href="#Example-2-Use-of-Stdout">Example 2: Use of Stdout</a><ul>
<li><a href="#pipe--管道符和stdout">pipe (|) 管道符和stdout</a></li>
</ul>
</li>
<li><a href="#Example-3-Use-of-Stdin-and-Stdout">Example 3: Use of Stdin and Stdout</a></li>
<li><a href="#Example-4-Use-of-Stderr">Example 4: Use of Stderr</a></li>
</ul>
<h1 id="原文"><a href="#原文" class="headerlink" title="原文"></a>原文</h1><p><span class="exturl" data-url="aHR0cHM6Ly93d3cubGludXhjb25zdWx0YW50Lm9yZy9ob3ctdG8tdXNlLXRoZS1zdGRpbi1zdGRlcnItYW5kLXN0ZG91dC1zdHJlYW1zLWluLWJhc2gv" title="https://www.linuxconsultant.org/how-to-use-the-stdin-stderr-and-stdout-streams-in-bash/">How to Use the Stdin, Stderr, and Stdout Streams in Bash – Linux Consultant<i class="fa fa-external-link"></i></span></p>
<h1 id="引言"><a href="#引言" class="headerlink" title="引言"></a>引言</h1><p>当Linux操作系统启动时，将会有三个流被打开。它们是<strong>stdin</strong>、<strong>stdout</strong>和<strong>stderr</strong>。</p>
<p><strong>stdin</strong> 的全称是标准输入，用于接受用户的输入。</p>
<p><strong>stdout</strong> 的完整形式是标准输出，用于将命令的输出存储到stdout流中。</p>
<p><strong>stderr</strong> 的完整形式是标准错误，用于将任何命令产生的错误信息存储到数据流中。</p>
<p><strong>stdin</strong>、<strong>stdout</strong> 和 <strong>stderr</strong> 的相应数字标识符值为<strong>0</strong>、<strong>1</strong>和<strong>2</strong>。</p>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2023/03/15/stdinouterr/#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://whitestore.top/2023/03/11/rocketshengchanzhe/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="阿东">
      <meta itemprop="description" content="随遇而安">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="爱看书的阿东">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/03/11/rocketshengchanzhe/" class="post-title-link" itemprop="url">【RocketMq】Rocket 生产者相关知识点 - 消息发送者参数详解</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-03-11 07:27:49" itemprop="dateCreated datePublished" datetime="2023-03-11T07:27:49+08:00">2023-03-11</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2023-06-15 21:10:39" itemprop="dateModified" datetime="2023-06-15T21:10:39+08:00">2023-06-15</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/RocketMq/" itemprop="url" rel="index"><span itemprop="name">RocketMq</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/03/11/rocketshengchanzhe/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/03/11/rocketshengchanzhe/" itemprop="commentCount"></span>
    </a>
  </span>
  
  <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>9.5k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>9 分钟</span>
            </span>
            <div class="post-description">rocketmq使用</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>#rocketmq</p>
<h1 id="引言"><a href="#引言" class="headerlink" title="引言"></a>引言</h1><p>首先注意本次讨论的RokcetMq源码版本为 <strong>4.9.4</strong>，距离5.0发布 的没有多久。</p>
<p>这一节针对RocketMq的生产者请求发送的部分细节进行阐述，主要包含了下面的内容：DefaultMQProducer 为生产者默认对象，这个对象继承自 ClientConfig，里面包含了请求者的通用配置，所以可以拆分为两个部分进行理解，第一部分为ClientConfig，第二部分为DefaultMQProducer。</p>
<h1 id="ClientConfig-部分"><a href="#ClientConfig-部分" class="headerlink" title="ClientConfig 部分"></a>ClientConfig 部分</h1><p>ClientConfig 定义了一些配置的获取方法，定义了命名空间等参数。无论是消息的发送者还是消费者都是通用的。</p>
<p>下面根据本次的版本的源代码介绍相关参数。</p>
<table>
<thead>
<tr>
<th>名称</th>
<th>描述</th>
<th>参数类型</th>
<th>默认值</th>
<th>有效值</th>
<th>重要性</th>
</tr>
</thead>
<tbody><tr>
<td>namesrvAddr</td>
<td>NameServer的地址列表</td>
<td>String</td>
<td>从-D系统参数rocketmq.namesrv.addr或环境变量。NAMESRV_ADDR</td>
<td></td>
<td></td>
</tr>
<tr>
<td>instanceName</td>
<td>客户端实例名称</td>
<td>String</td>
<td>从-D系统参数rocketmq.client.name获取，否则就是DEFAULT</td>
<td></td>
<td></td>
</tr>
<tr>
<td>clientIP</td>
<td>客户端IP</td>
<td>String</td>
<td>RemotingUtil.getLocalAddress()</td>
<td></td>
<td></td>
</tr>
<tr>
<td>namespace</td>
<td>客户端命名空间</td>
<td>String</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>accessChannel</td>
<td>设置访问通道</td>
<td>AccessChannel</td>
<td>LOCAL</td>
<td></td>
<td></td>
</tr>
<tr>
<td>clientCallbackExecutorThreads</td>
<td>客户端通信层接收到网络请求的时候，处理器的核数</td>
<td>int</td>
<td>Runtime.getRuntime().availableProcessors()</td>
<td></td>
<td></td>
</tr>
<tr>
<td>pollNameServerInterval</td>
<td>轮询从NameServer获取路由信息的时间间隔</td>
<td>int</td>
<td>30000，单位毫秒</td>
<td></td>
<td></td>
</tr>
<tr>
<td>heartbeatBrokerInterval</td>
<td>定期发送注册心跳到broker的间隔</td>
<td>int</td>
<td>30000，单位毫秒</td>
<td></td>
<td></td>
</tr>
<tr>
<td>persistConsumerOffsetInterval</td>
<td>作用于Consumer，持久化消费进度的间隔</td>
<td>int</td>
<td>默认值5000，单位毫秒</td>
<td></td>
<td></td>
</tr>
<tr>
<td>pullTimeDelayMillsWhenException</td>
<td>拉取消息出现异常的延迟时间设置</td>
<td>long</td>
<td>1000，单位毫秒</td>
<td></td>
<td></td>
</tr>
<tr>
<td>unitName</td>
<td>单位名称</td>
<td>String</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>unitMode</td>
<td>单位模式</td>
<td>boolean</td>
<td>false</td>
<td></td>
<td></td>
</tr>
<tr>
<td>vipChannelEnabled</td>
<td>是否启用vip netty通道以发送消息</td>
<td>boolean</td>
<td>从-D com.rocketmq.sendMessageWithVIPChannel参数的值，若无则是true</td>
<td></td>
<td></td>
</tr>
<tr>
<td>useTLS</td>
<td>是否使用安全传输。</td>
<td>boolean</td>
<td>从-D系统参数tls.enable获取，否则就是false</td>
<td></td>
<td></td>
</tr>
<tr>
<td>mqClientApiTimeout</td>
<td>mq客户端api超时设置</td>
<td>int</td>
<td>3000，单位毫秒</td>
<td></td>
<td></td>
</tr>
<tr>
<td>language</td>
<td>客户端实现语言</td>
<td>LanguageCode</td>
<td>LanguageCode.<em>JAVA</em></td>
<td></td>
<td></td>
</tr>
</tbody></table>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2023/03/11/rocketshengchanzhe/#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://whitestore.top/2023/03/11/rocketjianhua/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="阿东">
      <meta itemprop="description" content="随遇而安">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="爱看书的阿东">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/03/11/rocketjianhua/" class="post-title-link" itemprop="url">【RocketMq】使用Idea部署RocketMq 源代码（4.9.4）</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-03-11 07:24:00" itemprop="dateCreated datePublished" datetime="2023-03-11T07:24:00+08:00">2023-03-11</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2023-06-15 21:10:39" itemprop="dateModified" datetime="2023-06-15T21:10:39+08:00">2023-06-15</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/RocketMq/" itemprop="url" rel="index"><span itemprop="name">RocketMq</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/03/11/rocketjianhua/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/03/11/rocketjianhua/" itemprop="commentCount"></span>
    </a>
  </span>
  
  <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>5.6k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>5 分钟</span>
            </span>
            <div class="post-description">部署和使用RocketMq</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>#rocketmq  </p>
<h1 id="一、介绍"><a href="#一、介绍" class="headerlink" title="一、介绍"></a>一、介绍</h1><p>笔记为主，Idea部署RocketMq的简化流程。</p>
<p><span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL2FwYWNoZS9yb2NrZXRtcQ==" title="https://github.com/apache/rocketmq">https://github.com/apache/rocketmq<i class="fa fa-external-link"></i></span></p>
<h1 id="二、提示"><a href="#二、提示" class="headerlink" title="二、提示"></a>二、提示</h1><h2 id="2-1-IDEA版本"><a href="#2-1-IDEA版本" class="headerlink" title="2.1 IDEA版本"></a>2.1 IDEA版本</h2><p>个人使用的Idea版本。</p>
<p><img src="https://adong-picture.oss-cn-shenzhen.aliyuncs.com/adong/20220826144547.png" alt=""></p>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2023/03/11/rocketjianhua/#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://whitestore.top/2023/03/11/shangyong/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="阿东">
      <meta itemprop="description" content="随遇而安">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="爱看书的阿东">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/03/11/shangyong/" class="post-title-link" itemprop="url">【RocketMq】商用RocketMq和开源RocketMq的兼容问题解决方案</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-03-11 07:21:11" itemprop="dateCreated datePublished" datetime="2023-03-11T07:21:11+08:00">2023-03-11</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2023-06-15 21:10:39" itemprop="dateModified" datetime="2023-06-15T21:10:39+08:00">2023-06-15</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/RocketMq/" itemprop="url" rel="index"><span itemprop="name">RocketMq</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/03/11/shangyong/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/03/11/shangyong/" itemprop="commentCount"></span>
    </a>
  </span>
  
  <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>25k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>23 分钟</span>
            </span>
            <div class="post-description">学习和使用RocketMq</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="引言"><a href="#引言" class="headerlink" title="引言"></a>引言</h1><p>在阿里云的官方网站提供了RocketMq的商用版本，但是个人在项目应用上发现和SpirngBoot以及Spring Cloud（Alibaba）等开源的RocketMQ依赖虽然可以正常兼容，但是依然出现了注解失效、启动报错，商用和开源版本的不兼容导致部分代码要重复编写的蛋疼问题。</p>
<p>这样的兼容问题不是简单加个SDK依赖，切换到商用配置就可以直接使用的（因为个人起初真就是这么想），为了避免后面再遇到这种<strong>奇葩</strong>的开发测试用开源RocketMq，生产环境需要使用商用集群的RocketMq的混合配置的业务场景，个人花了小半天时间熟读阿里云的接入文档，加上各种尝试和测试，总结出一套可以快速使用的兼容模板方案。</p>
<p>如果不了解阿里云商用RocketMq，可以看最后一个大节的【阿里云商用RocketMq介绍】介绍。个人的兼容方案灵感来自于官方提供的这个DEMO项目：<span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL0FsaXdhcmVNUS9tcS1kZW1vL3RyZWUvbWFzdGVyL3NwcmluZ2Jvb3QvamF2YS1zcHJpbmdib290LWRlbW8=" title="https://github.com/AliwareMQ/mq-demo/tree/master/springboot/java-springboot-demo">springboot/java-springboot-demo<i class="fa fa-external-link"></i></span>。</p>
<p>注意本方案是基于<strong>SpringBoot2.X</strong>和 <strong>Spring cloud Alibaba</strong> 的两个项目环境构建项目基础，在SpringBoot上只做了生产者的配置，而在Spring Cloud Alibaba的Nacos上进行了生产者和消费者的完整兼容方案。</p>
<p>最后注意兼容集成的版本为商用RocketMq使用<strong>4.x</strong>版本，最近新出的5.X 的版本并<strong>未进行测试</strong>，不保证正常使用。</p>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2023/03/11/shangyong/#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://whitestore.top/2023/03/11/codingparctice/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="阿东">
      <meta itemprop="description" content="随遇而安">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="爱看书的阿东">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/03/11/codingparctice/" class="post-title-link" itemprop="url">【Java】Best coding practices every java developer should</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-03-11 07:13:34" itemprop="dateCreated datePublished" datetime="2023-03-11T07:13:34+08:00">2023-03-11</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2023-07-16 14:28:09" itemprop="dateModified" datetime="2023-07-16T14:28:09+08:00">2023-07-16</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java/" itemprop="url" rel="index"><span itemprop="name">Java</span></a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/03/11/codingparctice/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/03/11/codingparctice/" itemprop="commentCount"></span>
    </a>
  </span>
  
  <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>9.8k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>9 分钟</span>
            </span>
            <div class="post-description">Best coding practices every java developer should follow</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="原文"><a href="#原文" class="headerlink" title="原文"></a>原文</h1><p><span class="exturl" data-url="aHR0cHM6Ly9tZWRpdW0uY29tL0BhYmhpc2hla3NpbmdoamF2YS9iZXN0LWNvZGluZy1wcmFjdGljZXMtZXZlcnktamF2YS1kZXZlbG9wZXItc2hvdWxkLWZvbGxvdy03Yjc3NTI3YTcwNDgjaWRfdG9rZW49ZXlKaGJHY2lPaUpTVXpJMU5pSXNJbXRwWkNJNklqSTFOV05qWVRabFl6STRNVEEyTURKa09EQmlaV000T1dVME5UWmpORFE1TldRM05ERTRZbUlpTENKMGVYQWlPaUpLVjFRaWZRLmV5SnBjM01pT2lKb2RIUndjem92TDJGalkyOTFiblJ6TG1kdmIyZHNaUzVqYjIwaUxDSnVZbVlpT2pFMk56Z3pOekEzTkRVc0ltRjFaQ0k2SWpJeE5qSTVOakF6TlRnek5DMXJNV3MyY1dVd05qQnpNblJ3TW1FeWFtRnROR3hxWkdOdGN6QXdjM1IwWnk1aGNIQnpMbWR2YjJkc1pYVnpaWEpqYjI1MFpXNTBMbU52YlNJc0luTjFZaUk2SWpFd01qVXpOakF3TmpZMU1UQTVORFF4TnpNNE15SXNJbVZ0WVdsc0lqb2llbmhrYzJJMk5qWkFaMjFoYVd3dVkyOXRJaXdpWlcxaGFXeGZkbVZ5YVdacFpXUWlPblJ5ZFdVc0ltRjZjQ0k2SWpJeE5qSTVOakF6TlRnek5DMXJNV3My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ZvvG7yHMAH0R51l7xn-nUMlMnKZN12wb-VZCSbw86d4-kKgrr9b18dP7R3JDlNhUo3CEL5lwZpPWdMj3gHzRw0ZBr94HWLSg">Best coding practices every java developer should follow<i class="fa fa-external-link"></i></span></p>
<h2 id="目录"><a href="#目录" class="headerlink" title="目录"></a>目录</h2><ul>
<li><a href="#引言">引言</a></li>
<li><a href="#4-尽可能让变量私有化">4. 尽可能让变量私有化</a></li>
<li><a href="#6-警惕冗余初始化">6. 警惕冗余初始化</a></li>
<li><a href="#5-Stringbuilder替换字符串拼接争议">5. Stringbuilder替换字符串拼接【争议】</a></li>
<li><a href="#15-dry和kiss">15. dry和kiss</a></li>
<li><a href="#14-Solid">14. Solid</a></li>
<li><a href="#7-尽可能使用增强for循环或者foreach">7. 尽可能使用增强for循环或者foreach</a></li>
<li><a href="#13-日志打印规则">13. 日志打印规则</a></li>
<li><a href="#12-Hardcoding硬编码">12. Hardcoding硬编码</a></li>
<li><a href="#11-注释">11. 注释</a></li>
<li><a href="#10-避免创建不必要对象">10. 避免创建不必要对象</a></li>
<li><a href="#9-返回空集合而不是null">9. 返回空集合而不是null</a></li>
<li><a href="#8-精度选择">8. 精度选择</a></li>
<li><a href="#1-项目结构">1. 项目结构</a></li>
<li><a href="#2-遵循命名规范">2. 遵循命名规范</a></li>
<li><a href="#3-不要吞异常">3. 不要吞异常</a></li>
<li><a href="#16-使用枚举替代静态常量建议">16. 使用枚举替代静态常量【建议】</a></li>
<li><a href="#17-按作用域划分成员变量">17. 按作用域划分成员变量</a></li>
<li><a href="#18-在数字字段中使用下划线建议">18. 在数字字段中使用下划线【建议】</a></li>
<li><a href="#总结">总结</a></li>
<li><a href="#参考">参考</a></li>
</ul>
<h1 id="引言"><a href="#引言" class="headerlink" title="引言"></a>引言</h1><p>把标题翻译成中文在国内也是一个老生常谈的问题：编程习惯和编码规范。</p>
<p>这篇文章大部分观点和国内的规范习惯类似，令我好奇的是外国人是如何理解这些内容的？</p>
<p>注意本文的Tips排序是打乱的，个人把感兴趣放到了前面来了。这篇文章的评论区非常精彩，这里一并整合了评论区的读者观点。</p>
<p>不管是学习还是习老外的思考方式，或是大在评论区当中看读者的讨论和纠正错误，阅读本文都是值得推荐的。</p>
<p>抱着半信半疑的态度学习这些内容，你会得到比单纯的了解和接受建议更多的收获。</p>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2023/03/11/codingparctice/#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/3/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/3/">3</a><span class="page-number current">4</span><a class="page-number" href="/page/5/">5</a><span class="space">&hellip;</span><a class="page-number" href="/page/24/">24</a><a class="extend next" rel="next" href="/page/5/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">阿东</p>
  <div class="site-description" itemprop="description">随遇而安</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">239</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">36</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">37</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL2xhenlUaW1lcw==" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;lazyTimes"><i class="fa fa-fw fa-github"></i>GitHub</span>
      </span>
      <span class="links-of-author-item">
        <span class="exturl" data-url="bWFpbHRvOjEwOTc0ODM1MDhAcXEuY29t" title="E-Mail → mailto:1097483508@qq.com"><i class="fa fa-fw fa-envelope"></i>E-Mail</span>
      </span>
  </div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title">
      <i class="fa fa-fw fa-link"></i>
      友情链接
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <span class="exturl" data-url="aHR0cHM6Ly93d3cuNTJwb2ppZS5jbi9ob21lLnBocD9tb2Q9c3BhY2UmdWlkPTE0OTc3MTgmZG89dGhyZWFkJnZpZXc9bWUmZnJvbT1zcGFjZQ==" title="https:&#x2F;&#x2F;www.52pojie.cn&#x2F;home.php?mod&#x3D;space&amp;uid&#x3D;1497718&amp;do&#x3D;thread&amp;view&#x3D;me&amp;from&#x3D;space">吾爱破解</span>
        </li>
        <li class="links-of-blogroll-item">
          <span class="exturl" data-url="aHR0cHM6Ly9qdWVqaW4uaW0vdXNlci8yOTk5MTIzNDUyNjI2MzY2" title="https:&#x2F;&#x2F;juejin.im&#x2F;user&#x2F;2999123452626366">掘金</span>
        </li>
        <li class="links-of-blogroll-item">
          <span class="exturl" data-url="aHR0cHM6Ly9zZWdtZW50ZmF1bHQuY29tL3UvbGF6eXRpbWVz" title="https:&#x2F;&#x2F;segmentfault.com&#x2F;u&#x2F;lazytimes">思否</span>
        </li>
    </ul>
  </div>

      </div>

      <div class="wechat_OA">
        <span>欢迎关注我的公众号</span>
        <br>
          <!-- 这里添加你的二维码图片 -->
        <img src ="https://adong-picture.oss-cn-shenzhen.aliyuncs.com/adong/wechat_channel.jpg">
      </div>
        <div class="back-to-top motion-element">
          <i class="fa fa-arrow-up"></i>
          <span>0%</span>
        </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">阿东</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
      <span class="post-meta-item-text">站点总字数：</span>
    <span title="站点总字数">2m</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span class="post-meta-item-text">站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">29:50</span>
</div>
  <div class="powered-by">由 <span class="exturl theme-link" data-url="aHR0cHM6Ly9oZXhvLmlv">Hexo</span> & <span class="exturl theme-link" data-url="aHR0cHM6Ly90aGVtZS1uZXh0Lm9yZw==">NexT.Gemini</span> 强力驱动
  </div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js"></script>
  <script src="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : true,
      appId      : 'qMUpEEvBgXaMDD1b0ftgi9xr-gzGzoHsz',
      appKey     : 'UCdfT4Rfih6MO6y8DI4fstf6',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : false,
      lang       : 'zh-CN' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
